package com.chencs.app.lianmeng.service;

import com.chencs.app.AppCommon;
import com.chencs.app.lianmeng.mapper.LMProductMapper;
import com.chencs.vo.biz.lianmeng.Lmkey;
import com.chencs.vo.net.lmrequest.LmKeyRequest;
import com.chencs.vo.net.lmresponse.LmKeyResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Created by Administrator on 2018-8-9.
 */
@Service
public class LMSearchSer {

    @Autowired
    private LMProductMapper productMapper;

    /**
     *
     * 获取热门关键词
     */
    public LmKeyResponse getKeys(LmKeyRequest request){
        LmKeyResponse response = new LmKeyResponse();
        List<Lmkey> lmkeyList = productMapper.getKeyBySex(request.getSex());
        if(CollectionUtils.isEmpty(lmkeyList)){
            response.setCode(AppCommon.NULL);
            response.setMsg(AppCommon.NULLMSG);
        }else{
            response.setLmkeyList(lmkeyList);
            response.setMsg(AppCommon.SUCCESSMSG);
            response.setCode(AppCommon.SUCCESS);
        }
        return  response;
    }

}
